﻿// Copyright (c) Argo Zhang (argo@163.com). All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
// Website: https://www.blazor.zone or https://argozhang.github.io/

using Microsoft.AspNetCore.Components;

namespace BootstrapBlazor.Components;

/// <summary>
/// <see cref="NavbarItem"/> 的分组容器组件
/// </summary>
public sealed partial class NavbarGroup
{
    /// <summary>
    /// 获得 样式类集合 
    /// </summary>
    /// <returns></returns>
    private string? ClassString => CssBuilder.Default()
        .AddClass("navbar-nav me-auto", ParentState.IsHorizontal)
        .AddClass("navbar-nav-scroll", ParentState.IsHorizontal && IsScroll)
        .AddClass("navbar-v-start", !ParentState.IsHorizontal && !IsTail)
        .AddClass("navbar-v-end", !ParentState.IsHorizontal && IsTail)
        .AddClassFromAttributes(AdditionalAttributes)
        .Build();

    /// <summary>
    /// 获得/设置 父级 <see cref="Navbar"/> 组件的状态
    /// </summary>
    [CascadingParameter]
    private NavbarState ParentState { get; set; } = new();

    /// <summary>
    /// 获得/设置 是否显示在尾部 水平时显示在右边，垂直时显示在下边
    /// </summary>
    [Parameter]
    public bool IsTail { get; init; }

    /// <summary>
    /// 获得/设置 是否在折叠导航栏的可切换内容中启用垂直滚动，默认启用，仅在水平菜单中生效
    /// </summary>
    [Parameter]
    public bool IsScroll { get; init; } = true;

    /// <summary>
    /// 获得/设置 子组件内容
    /// </summary>
    [Parameter]
    public RenderFragment? ChildContent { get; set; }
}
